<?php

namespace App\Repository\Repositories;

use App\Repository\Repositories\Interfaces\ProjectRepository;
use App\Repository\Models\Project;

/**
 * Class ProjectRepositoryEloquent.
 *
 * @package namespace App\Repository\Repositories;
 */
class ProjectRepositoryEloquent extends BaseRepository implements ProjectRepository
{
    /**
     * 搜索
     * @var array
     */
    protected $fieldSearchable = [
        'id',
        'title',
        'announcement_type',
        'purchase_mode',
        'purchase_type',
        'project_owner',
        'created_at'=>'between',
        'project_type'=>'in',
        'region.id',
        'admin_user.name'=>'like',
    ];

    /**
     * 多字段联合模糊查询,前端查询字段名keyword
     * @var array
     */
    public $fieldFuzzySearch = [
        'title',
        //'project_owner',
        'admin_user.name',
    ];
    public $fieldSearchReplace = [
        'city_id' => 'region.id',
    ];
    /**
     * 可关联查询的字段
     */
    public $withAllow = [
        'region',
        'admin_user'
    ];
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return Project::class;
    }
    public function indexNewList($limit)
    {
        // TODO: Implement indexNewList() method.
        $lastTenList = Project::query()->where(['check_status'=>'pass'])->limit($limit)->orderBy('created_at','desc')->get()->toArray();
        return $lastTenList;
    }
}
